package com.ruoyi.board.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.board.domain.StockBoardIndustryConsThs;
import com.ruoyi.board.service.IStockBoardIndustryConsThsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 同花顺-成份股-行业名称Controller
 * 
 * @author leng.xz
 * @date 2024-05-17
 */
@Controller
@RequestMapping("/board/IndustryConsThs")
public class StockBoardIndustryConsThsController extends BaseController
{
    private String prefix = "board/IndustryConsThs";

    @Autowired
    private IStockBoardIndustryConsThsService stockBoardIndustryConsThsService;

    @RequiresPermissions("board:IndustryConsThs:view")
    @GetMapping()
    public String IndustryConsThs()
    {
        return prefix + "/IndustryConsThs";
    }

    /**
     * 查询同花顺-成份股-行业名称列表
     */
    @RequiresPermissions("board:IndustryConsThs:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StockBoardIndustryConsThs stockBoardIndustryConsThs)
    {
        startPage();
        List<StockBoardIndustryConsThs> list = stockBoardIndustryConsThsService.selectStockBoardIndustryConsThsList(stockBoardIndustryConsThs);
        return getDataTable(list);
    }

    /**
     * 导出同花顺-成份股-行业名称列表
     */
    @RequiresPermissions("board:IndustryConsThs:export")
    @Log(title = "同花顺-成份股-行业名称", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StockBoardIndustryConsThs stockBoardIndustryConsThs)
    {
        List<StockBoardIndustryConsThs> list = stockBoardIndustryConsThsService.selectStockBoardIndustryConsThsList(stockBoardIndustryConsThs);
        ExcelUtil<StockBoardIndustryConsThs> util = new ExcelUtil<StockBoardIndustryConsThs>(StockBoardIndustryConsThs.class);
        return util.exportExcel(list, "IndustryConsThs");
    }

    /**
     * 新增同花顺-成份股-行业名称
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存同花顺-成份股-行业名称
     */
    @RequiresPermissions("board:IndustryConsThs:add")
    @Log(title = "同花顺-成份股-行业名称", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(StockBoardIndustryConsThs stockBoardIndustryConsThs)
    {
        return toAjax(stockBoardIndustryConsThsService.insertStockBoardIndustryConsThs(stockBoardIndustryConsThs));
    }

    /**
     * 修改同花顺-成份股-行业名称
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        StockBoardIndustryConsThs stockBoardIndustryConsThs = stockBoardIndustryConsThsService.selectStockBoardIndustryConsThsById(id);
        mmap.put("stockBoardIndustryConsThs", stockBoardIndustryConsThs);
        return prefix + "/edit";
    }

    /**
     * 修改保存同花顺-成份股-行业名称
     */
    @RequiresPermissions("board:IndustryConsThs:edit")
    @Log(title = "同花顺-成份股-行业名称", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(StockBoardIndustryConsThs stockBoardIndustryConsThs)
    {
        return toAjax(stockBoardIndustryConsThsService.updateStockBoardIndustryConsThs(stockBoardIndustryConsThs));
    }

    /**
     * 删除同花顺-成份股-行业名称
     */
    @RequiresPermissions("board:IndustryConsThs:remove")
    @Log(title = "同花顺-成份股-行业名称", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(stockBoardIndustryConsThsService.deleteStockBoardIndustryConsThsByIds(ids));
    }
}
